<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="../include/header.jsp" %>
<script type="text/javascript">
 function state_change(){
	 form_state.action="${path}/class1/class1_list.do";
	 form_state.submit(); 
 }
</script>
</head>
<body>
<h2>요리강좌게시판</h2>
<!-- state폼 -->
<c:if test="${sessionScope.userid == 'admin' }">
<form name="form_state" id="form_state" method="post">
 <select id="state_option" name="state_option" onchange="state_change();">
  <c:choose>
  <c:when test="${map.state=='multi'}">
    <option value="multi" selected>전체</option>
    <option value="0">0(승인대기)</option>
    <option value="1">1(승인완료)</option>
    <option value="2">2(강좌완료)</option>
    <option value="3">3(폐강됨)</option>
   </c:when>
   <c:when test="${map.state=='0'}">
    <option value="multi">전체</option>
    <option value="0" selected>0(승인대기)</option>
    <option value="1">1(승인완료)</option>
    <option value="2">2(강좌완료)</option>
    <option value="3">3(폐강됨)</option>
   </c:when>
   <c:when test="${map.state=='1'}">
    <option value="multi">전체</option>
    <option value="0">0(승인대기)</option>
    <option value="1" selected>1(승인완료)</option>
    <option value="2">2(강좌완료)</option>
    <option value="3">3(폐강됨)</option>
   </c:when>
   <c:when test="${map.state=='2'}">
    <option value="multi">전체</option>
    <option value="0">0(승인대기)</option>
    <option value="1">1(승인완료)</option>
    <option value="2" selected>2(강좌완료)</option>
    <option value="3">3(폐강됨)</option>
   </c:when>
   <c:when test="${map.state=='3'}">
    <option value="multi">전체</option>
    <option value="0">0(승인대기)</option>
    <option value="1">1(승인완료)</option>
    <option value="2">2(강좌완료)</option>
    <option value="3" selected>3(폐강됨)</option>>
   </c:when>
 </c:choose>
  </select>
 </form>
</c:if>

<table border="1" style="width:898px; margin:0 auto;">
 <tr align="center">
  <td style="width:30px;">No</td>
  <td style="width:100px;">강사</td>
  <td style="width:318px;">제목</td>
  <td style="width:100px;">레시피</td>
  <td style="width:200px;">강좌일</td>
  <td style="width:80px;">수강인원</td>
  <td style="width:70px;">조회수</td>
 </tr>
  <c:forEach var="row" items="${map.list}">
  <tr align="center">
   <td>${row.idx}</td>
   <td>${row.c_name}(${row.userid})</td>
   <td><a href="${path}/class1/class1_detail.do?idx=${row.idx}">${row.subject}</a></td>
   <td>${row.recipe_idx1}<c:if test="${row.recipe_idx2!=0}">,${row.recipe_idx2}</c:if></td>
   <td>${row.class_date}</td>
   <td><c:if test="${row.cnt==10}"><font color=red>마감</font></c:if><c:if test="${row.cnt<10}">${row.cnt}/10</c:if></td>
   <td>${row.hit}</td>
  </tr>
 </c:forEach>
</table>
<c:if test="${sessionScope.userid != null}">
<div id="myList">
<c:if test="${map.myList.size()>0}">
<hr>
<h2>내가 개설한 강좌</h2>
<table border="1" style="width:898px; margin:0 auto;">
  <tr align="center">
  <td style="width:30px;">No</td>
  <td style="width:100px;">강사</td>
  <td style="width:298px;">제목</td>
  <td style="width:100px;">레시피</td>
  <td style="width:150px;">강좌일</td>
  <td style="width:80px;">수강인원</td>
  <td style="width:50px;">조회수</td>
  <td style="width:90px;">상태</td>
 </tr>
  <c:forEach var="row" items="${map.myList}">
  <tr align="center">
   <td>${row.idx}</td>
   <td>${row.c_name}(${row.userid})</td>
   <td><a href="${path}/class1/class1_detail.do?idx=${row.idx}">${row.subject}</a></td>
   <td>${row.recipe_idx1}<c:if test="${row.recipe_idx2!=0}">,${row.recipe_idx2}</c:if></td>
   <td>${row.class_date}</td>
   <td>${row.cnt}/15</td>
   <td>${row.hit}</td>
   <td>
   <c:if test="${row.state=='0'}"><font color=#cccccc>승인대기</font></c:if>
   <c:if test="${row.state=='1'}"><font color=blue>승인완료</font></c:if>
   <c:if test="${row.state=='2'}"><font color=orange>강좌완료</font></c:if>
   <c:if test="${row.state=='3'}"><font color=red>폐강</font></c:if>
  </td>
  </tr>
 </c:forEach>
</table>
</c:if>
<hr>
<c:if test="${map.myOrderList.size()>0}">
<h2>내가 수강신청한 강좌</h2>
<table border="1" style="width:898px; margin:0 auto;">
  <tr align="center">
  <td style="width:30px;">No</td>
  <td style="width:100px;">강사</td>
  <td style="width:298px;">제목</td>
  <td style="width:100px;">레시피</td>
  <td style="width:150px;">강좌일</td>
  <td style="width:80px;">수강인원</td>
  <td style="width:50px;">조회수</td>
  <td style="width:90px;">상태</td>
 </tr>
  <c:forEach var="row" items="${map.myOrderList}">
  <tr align="center">
   <td>${row.r_idx}</td>
   <td>${row.c_name}(${row.userid})</td>
   <td><a href="${path}/class1/class1_my_resist.do?idx=${row.idx}&r_idx=${row.r_idx}&userid=${sessionScope.userid}">${row.subject}</a></td>
   <td>${row.recipe_idx1}<c:if test="${row.recipe_idx2!=0}">,${row.recipe_idx2}</c:if></td>
   <td>${row.class_date}</td>
   <td>${row.cnt}/15</td>
   <td>${row.hit}</td>
   <td>
   <c:if test="${row.state=='0'}"><font color=#cccccc>승인대기</font></c:if>
   <c:if test="${row.state=='1'}"><font color=blue>승인완료</font></c:if>
   <c:if test="${row.state=='2'}"><font color=orange>강좌완료</font></c:if>
   <c:if test="${row.state=='3'}"><font color=red>폐강</font></c:if>
  </td>
  </tr>
 </c:forEach>
</table>
</c:if>


</div>

</c:if>
</body>
</html>